package com.hunzi.config;

import com.hunzi.interceptor.AdminLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册定义拦截器
        //addPathPatterns() ，表示拦截的路径
        //excludePathPatterns() 表示不拦截的路径
        //登录页面 和 判断登录的页面都需要放行
        registry.addInterceptor ( new AdminLoginInterceptor () ).addPathPatterns ( "/admin/**" ).excludePathPatterns
                ( "/admin/login" , "/admin/adminuser/login");
    }
}
